package com.ccdt.tv.smartrecommend.view.bean;

import android.util.Log;

import com.ccdt.tv.smartrecommend.utils.CheckUtils;

/**
 * Created by wudz on 2017/10/11.
 */

public abstract class BaseBean {
    private static final String TAG="BaseBean";
    private static final String CTAG="CHECK_TAG";
    private static int count=0;
    //唯一标识名称
    private String id;
    //id标志不可为空或者""
    public BaseBean(String id)
    {
        this.id=id;
    }
    public BaseBean()
    {
        this.id=createId();
        Log.i(TAG,"BaseBean create auto id:"+id);
    }
    public static String createId()
    {
        return "id:"+(count++);
    }
    public String getId() {
        return id;
    }
    public void setId(String id)
    {
        this.id=id;
    }
    //用于测试参数测正确性 以及用于设置一些无参数情况下默认参数
    public void check()
    {
        Log.i(CTAG,"check:ClassName:"+getClass().getSimpleName());
        CheckUtils.checkNonNullString(id,"",true,"id is error!");
    }

    @Override
    public String toString() {
        return " -- " +
                "id=" + id ;
    }
    @Override
    public boolean equals(Object obj) {
        if(super.equals(obj))
            return true;
        if(obj==null)
            return false;
        if(obj instanceof BaseBean)
        {
            BaseBean o=(BaseBean)obj;
            if(o.getId()==null || o.getId().equals(""))
                throw new IllegalArgumentException("BaseDefaultResource rid is invaild!");
            if(getId().equals(o.getId()))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        return false;
    }

}
